<CFQUERY NAME="qryCHECKMAIN" DATASOURCE=#client.company_dsn#>
	SELECT *
	FROM ECRGFORMS
	WHERE COPYTOFORMCODE = '#GetForm.COPYTOFORMCODE#'
</CFQUERY>
<CFSET sAutogenVal = "">
<CFLOOP INDEX="x" FROM="1" TO="5">
	<CFIF evaluate("qryCHECKMAIN.PK_FIELD" & x) NEQ "">
		<CFSET session.sufvalue = evaluate("url." & evaluate("qryCHECKMAIN.PK_FIELD" & x))>
		<CFSET sAutogenVal = evaluate("url." & evaluate("qryCHECKMAIN.PK_FIELD" & x))>
	</CFIF>
</CFLOOP>

<CFQUERY NAME="GetEntry" DATASOURCE="#table_dsn#" MAXROWS=1>
   	SELECT *
	FROM #GetForm.TABLENAME_FK#
	WHERE (PERSONNELIDNO = '#GetEmployee.PERSONNELIDNO#')
	<CFLOOP INDEX="x" FROM="1" TO="5">
		<CFIF evaluate("GetForm.PK_FIELD" & x) NEQ "">
			<CFSET theVal = evaluate("url." & evaluate("GetForm.PK_FIELD" & x))>
			AND (#ucase(evaluate("GetForm.PK_FIELD" & x))# = '#theVal#')
		</CFIF>
	</CFLOOP>
 </CFQUERY>
<CFSET session.sCopyMe="yes">
<CFIF NOT(GetEntry.RecordCount)>
	<CFSET appname1	= "Editing " & GetForm.DESCRIPTION>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="#appname1#">
	<BR><BR><B>Unauthorized access detected!</B><BR><BR>
	Please use the standard editor to avoid
	being reported for illegal use of the software.
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
	<CFABORT>
</CFIF>
<CFSET appname1	= "Copying " & GetForm.DESCRIPTION>
<CFSET sAction 	= "Copy">

	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="#appname1#">

	<CFOUTPUT>
		<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=2 BGCOLOR="#client.color_tblhead#" WIDTH="100%" HEIGHT=33>
		<FORM ACTION="#eform.sender#" METHOD="post" NAME="eForm">
		<TR>
			<TD>
				&nbsp;
				<INPUT TYPE="submit" NAME="Save"  VALUE="#sAction#" CLASS="bitbtn">
				<INPUT TYPE="submit" NAME="Cancel" VALUE="Back" CLASS="bitbtn">
				<INPUT TYPE="hidden" NAME="hidAutoVal" VALUE="#sAutogenVal#">
			</TD>
		</TR>
		</TABLE>
	</CFOUTPUT>

	<HR>
	<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=5 WIDTH="100%">
	<TR VALIGN="bottom">
		<CFOUTPUT>
			<TD ALIGN="right"><IMG SRC="#client.image_path##session.site_ibose#"></TD>
			<TD NOWRAP CLASS="bold14" WIDTH="100%"><FONT FACE="Impact" SIZE="+2">#client.companyname#</FONT><BR>#GetForm.DESCRIPTION#</TD>
			<TD NOWRAP ALIGN="right"><IMG SRC="#client.icon_path#print.gif" BORDER=0> <A HREF="javascript: window.print();" CLASS="regular11">Printable version</A></TD>
		</CFOUTPUT>
	</TR>
	</TABLE>

	<TABLE BORDER=0 CELLSPACING=3 CELLPADDING=0 WIDTH="100%" BGCOLOR="#FFFFFF">
	<CFOUTPUT QUERY="GetFields" GROUP="FIELDGROUP">
		<CFIF len(trim(FIELDGROUP)) NEQ 0>
			<TR>
				<TD COLSPAN=3>
					<CFMODULE TEMPLATE="#client.common_path#cfm_group.cfm" CAPTION="#FIELDGROUP# #HINT#">
				</TD>
			</TR>
		</CFIF>

		<CFOUTPUT>
		<!--- get the value of the entry --->
		<CFPARAM NAME="Form.edt#COLUMNNAME#" DEFAULT="">
		<CFSET sEntryValue = #evaluate("GetEntry." & COLUMNNAME)#>

		<TR VALIGN="top">
			<TD NOWRAP VALIGN="top">#COLUMNDESC#:</TD>
			<TD NOWRAP CLASS="bold14">
				<CFIF lcase(COLUMNREQUIRED) EQ "y">*</CFIF>
				&nbsp;
			</TD>
			<TD VALIGN="top" WIDTH="100%">
				<!--- store the original value --->
				<INPUT TYPE="hidden" NAME="old#COLUMNNAME#" VALUE="#sEntryValue#">

				<!--- Added by Mhel for Autogen Field --->
				<!--- Start --->
				<!--- get the autogen field of destination table --->
				<CFQUERY NAME="qryCopyToeForm" DATASOURCE=#client.company_dsn#>
					SELECT TABLENAME_FK
					FROM ECRGFORMS
					WHERE FORMCODE = '#GetForm.COPYTOFORMCODE#'
				</CFQUERY>

				<CFQUERY DATASOURCE="#client.global_dsn#" NAME="autogen">
					SELECT *
					FROM GSTAUTOGENFIELD
					WHERE TABLENAME = '#qryCopyToeForm.TABLENAME_FK#' AND
						  FIELDNAME = '#COLUMNNAME#'
				</CFQUERY>

				<CFIF autogen.RecordCount>
					<CFSET lAutoGen="Yes">
				<CFELSE>
					<CFSET lAutoGen="No">
				</CFIF>
				<!--- End --->

				<CFSWITCH EXPRESSION="#lcase(COLUMNTYPE)#">
				<!--- calendar lookup --->
					<CFCASE VALUE="ftdatetime">
						<INPUT TYPE="text" SZE=15 NAME="edt#COLUMNNAME#" VALUE="#DateFormat(sEntryValue,"mm/dd/yyyy")#" READONLY>
					</CFCASE>
					<!--- memo fields --->
					<CFCASE VALUE="ftmemo">
						<TEXTAREA COLS="77" ROWS="4" NAME="edt#COLUMNNAME#" READONLY>#sEntryValue#</TEXTAREA>
					</CFCASE>
					<!--- blob fields --->
					<CFCASE VALUE="ftblob,ftgraphic">
						interface not supported.
					</CFCASE>
					<CFDEFAULTCASE>
						<!--- Get size of form field --->
						<CFSWITCH EXPRESSION="#lcase(COLUMNTYPE)#">
					    <CFCASE VALUE="ftinteger,ftsmallint,ftfloat">
							<CFSET nFieldSize=15>
						</CFCASE>
						<CFDEFAULTCASE>
							<CFSET nFieldSize=Evaluate(PHYSICALWIDTH + 5)>
						</CFDEFAULTCASE>
						</CFSWITCH>
	
						<!--- there's a lookup --->
						<CFQUERY NAME="GetLookup" DATASOURCE="#client.global_dsn#">
							SELECT A.*, B.LEVELID
							FROM GSTLOOKUP A, GRGBOSETABLE B
							WHERE
								(A.MASTERTABLE = '#GetForm.TABLENAME_FK#') AND
								(A.MASTERFIELD = '#COLUMNNAME#') AND
								(A.LOOKUPTABLE = B.TABLENAME)
						</CFQUERY>
	
						<CFIF GetLookup.RecordCount>
							<!--- lookup edit --->
							<INPUT READONLY TYPE="text" SIZE=#nFieldSize# NAME="hid#COLUMNNAME#" VALUE="#sEntryValue#">
							<INPUT TYPE="hidden" NAME="edt#COLUMNNAME#" VALUE="#sEntryValue#">
	
							<CFSET sLkValue = "">
							<CFIF (#trim(GetLookup.LEVELID)# IS "") OR
								  (#trim(GetLookup.LOOKUPKEYFIELD)# IS "") OR
								  (#trim(GetLookup.LOOKUPRESULTFIELD)# IS "") OR
								  (#trim(GetLookup.LOOKUPTABLE)# IS "")>
								<I>*Lookup not properly setup.</I>
							<CFELSE>
								<!--- TblLocation, TblName, DisplayFlds, ReturnFld, FormName, FieldName, LookupName --->
								<CFSET sLkFlds = trim(GetLookup.LOOKUPKEYFIELD) & "," & trim(GetLookup.LOOKUPRESULTFIELD)>
								<!--- get the description in the lookup --->
								<CFIF len(trim(sEntryValue)) NEQ 0>
									<!--- get table location --->
									<!--- custom tag: parameter: DBLEVEL; return value: DSN --->
									<CFMODULE TEMPLATE="#client.common_path#cfm_leveldsn.cfm" DBLEVEL="#GetLookup.LEVELID#">
									<CFSET lk_dsn = DSN>
	
									<CFQUERY NAME="GetLkDesc" DATASOURCE="#lk_dsn#">
										SELECT #GetLookup.LOOKUPRESULTFIELD#
										FROM #GetLookup.LOOKUPTABLE#
										WHERE
											(#GetLookup.LOOKUPKEYFIELD# = '#sEntryValue#')
									</CFQUERY>
	
									<CFIF GetLkDesc.RecordCount>
										<CFSET sLkValue = "#evaluate("GetLkDesc." & GetLookup.LOOKUPRESULTFIELD)#">
									<CFELSE>
										<CFSET sLkValue = "[value not found in the lookup.]">
									</CFIF>
								</CFIF>
							</CFIF>
	
							<!--- lookup description --->
							&nbsp;
							<INPUT READONLY TYPE="text" NAME="lk#COLUMNNAME#" SIZE=60 VALUE="#sLkValue#">
						<CFELSEIF lAutoGen>
							<CFSET sSeed="#autogen.SEEDKEY#" & DateFormat(Now(), "YYYYMMDD")>
							<CFSET nCtrVal=autogen.CODELENGTH - Len(sSeed)>
	
							<CFQUERY DATASOURCE="#client.company_dsn#" NAME="autogenvalue">
								SELECT #COLUMNNAME#
								FROM #qryCopyToeForm.TABLENAME_FK#
								WHERE #COLUMNNAME# LIKE '#sSeed#%'
								ORDER BY #COLUMNNAME#
							</CFQUERY>
	
							<CFIF autogenvalue.RecordCount>
								<CFSET sFieldValue=Evaluate("autogenvalue.#COLUMNNAME#[autogenvalue.RecordCount]")>
	
								<CFIF sSeed IS Left(sFieldValue, Len(sSeed))>
									<CFSET sValue=Mid(sFieldValue, Len(sSeed) + 1, nCtrVal)>
									<CFSET nValue=LSParseNumber(sValue) + 1>
									<CFSET sValue=ToString(nValue)>
									<CFSET sValue=RJustify(sValue, nCtrVal)>
									<CFSET sValue=Replace(sValue, " ", "0", "ALL")>
									<CFSET sValue=sSeed & sValue>
								<CFELSE>
									<CFSET sValue=Replace(RJustify("1", nCtrVal), " ", "0", "ALL")>
									<CFSET sValue=sSeed & sValue>
								</CFIF>
							<CFELSE>
								<CFSET sValue=Replace(RJustify("1", nCtrVal), " ", "0", "ALL")>
								<CFSET sValue=sSeed & sValue>
							</CFIF>
							<!--- standard form edit --->
							<INPUT TYPE="text" NAME="edt#COLUMNNAME#" VALUE="#sValue#" SIZE=#nFieldSize# READONLY>
						<CFELSE>
							<INPUT TYPE="text" NAME="edt#COLUMNNAME#" VALUE="#sEntryValue#" READONLY SIZE=#nFieldSize#>
						</CFIF> <!--- check lookup --->
					</CFDEFAULTCASE>
				</CFSWITCH>
			</TD>
		</TR>
		</CFOUTPUT>
	</CFOUTPUT>
</FORM>
	</TABLE> <!--- 3rd table --->

<HR>
<I>* - Field that requires a value.</I>
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">